﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using HRM.api;
using DTO;
using HRM.Models;
namespace HRM.Controllers
{
    public class PQController : Controller
    {
        //
        // GET: /PQ/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetItems(long groupid) {
            List<Item> list = new List<Item>();
            list = new WebData().Items.GetModules(groupid);
            var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
            var jsonResult = new ContentResult
            {
                Content = JsonConvert.SerializeObject(list, settings),
                ContentType = "application/json"
            };
            return jsonResult;
        }

        public ActionResult GetAll()
        {
            var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
            var objs = new WebData().Items.GetAll();
            var jsonResult = new ContentResult
            {
                Content = JsonConvert.SerializeObject(objs, settings),
                ContentType = "application/json"
            };

            return jsonResult;
        }
    }
}
